<f:view xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:aui="http://liferay.com/faces/aui"
	xmlns:c="http://java.sun.com/jsp/jstl/core" 
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html" 
	xmlns:bridge="http://liferay.com/faces/bridge"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:example-cc="http://java.sun.com/jsf/composite/example-cc"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	
	<h:form id="measurementForm" styleClass="measurementForm" >
		<ui:include src="/jsf/appointment/common/appointment_information.xhtml" />
		<f:event listener="#{measurementFormController.loadData}" type="javax.faces.event.PreRenderComponentEvent" />
		<h:panelGroup styleClass="measurementFormTitle contentTitle" >
			<h:outputText value="Messprotokoll" styleClass="measurementFormTitleValue contentTitleValue" />
		</h:panelGroup>
		<h:panelGroup>
			<h:panelGrid columns="4" columnClasses="label-first, value-first, label-second, value-second" 
						styleClass="measurementPanel measurementGrid" >
				<p:outputLabel value="Objekt:" for="object" />
				<p:inputText id="object" value="#{measurementFormController.measurement.object}"
						styleClass="measurementInput" />
				<p:outputLabel value="Zählernummer:" for="energyMeterNumber" />
				<p:inputText id="energyMeterNumber" value="#{measurementFormController.measurement.energyMeterNumber}"
						styleClass="measurementInput" />
			
				<p:outputLabel value="Ort:" for="location" />
				<p:inputText id="location" value="#{measurementFormController.measurement.location}"
						styleClass="measurementInput" />
				<p:outputLabel value="Datum:" for="measurementDate" />
				<p:calendar id="measurementDate"
						value="#{measurementFormController.measurement.measurementDate}" required="true"
						navigator="true" showOn="button" disabledWeekends="true"
						timeZone="Europe/Zurich" converter="LocalDateConverter"
						minHour="7" maxHour="20" pattern="dd.MM.yyyy HH:mm"
						styleClass="measurementInput" />
			</h:panelGrid>
		</h:panelGroup>
		
		<p:dataTable var="measurementEntry" value="#{measurementFormController.measurementEntries}" 
	    			 sortBy="#{measurementEntry.currentCircuitNumber}" styleClass="electroOfficeTable measurementTable" >
	        
	        <p:columnGroup type="header" styleClass="measurementTableHeader" >  
                <p:row>  
                    <p:column headerText="Stromkreis" styleClass="headerTopic" />  
                    <p:column headerText="Ort/Anlageteil Schaltgerätekombination" styleClass="headerTopic" />  
                    <p:column headerText="Leitung/Kabel" styleClass="headerTopic" />
                    <p:column headerText="Überstromschutzeinrichtungen" colspan="2" styleClass="headerTopic" />
                    <p:column headerText="Messungen" colspan="4" styleClass="headerTopic" />
                    <p:column headerText="Fehlerstromschutzeinrichtung" colspan="3" styleClass="headerTopic" />
                    <p:column headerText="Drehfeld" />
                </p:row>
                 <p:row>  
                    <p:column headerText="Nr." styleClass="headerCol currentCircuitNumber" />  
                    <p:column headerText="Bezeichnung" styleClass="headerCol description" />  
                    <p:column headerText="Art/Leiteranzahl Querschnitt" styleClass="headerCol conductorCrossSection" />
                    <p:column headerText="Art Charakteristik" styleClass="headerCol characteristic" />
                    <p:column headerText="I-Nenn (A)" styleClass="headerCol ratedCurrent" />
                    <p:column headerText="PE Leitfähigkeit" styleClass="headerCol peConductibility" />
                    <p:column headerText="IK min (A)" styleClass="headerCol shortCircuitCurrent" />
                    <p:column headerText="R-Iso (M&#8486;)" styleClass="headerCol insulatingResistance" />
                    <p:column headerText="R-Iso > 999 M&#8486;" styleClass="headerCol insulatingResistanceIsBigger999" />
                    <p:column headerText="IdN (mA)" styleClass="headerCol fiRatedCurrent" />
                    <p:column headerText="Auslösestrom (mA)" styleClass="headerCol fiReleaseCurrent" />
                    <p:column headerText="Auslösezeit (ms)" styleClass="headerCol fiTimeInMillis" />
                    <p:column headerText="rechts" styleClass="headerCol rotatingFieldClockwise" />
                </p:row>
            </p:columnGroup>
	        
	        <p:column styleClass="measurementCol currentCircuitNumber" >
	            <p:inputText value="#{measurementEntry.currentCircuitNumber}"
	            		styleClass="measurementFormInput measurementFormInputCurrentCircuitNumber" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol description" >
	            <p:inputText value="#{measurementEntry.description}" 
	            		styleClass="measurementFormInput measurementFormInputDescription" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol conductorCrossSection" >
	            <p:inputText value="#{measurementEntry.conductorCrossSection}"
	            		styleClass="measurementFormInput measurementFormInputConductorCrossSection" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol characteristic" >
	            <p:inputText value="#{measurementEntry.characteristic}"
	            		styleClass="measurementFormInput measurementFormInputCharacteristic" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol ratedCurrent" >
	            <p:inputText value="#{measurementEntry.ratedCurrent}"
	            		styleClass="measurementFormInput measurementFormInputRatedCurrent" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol peConductibility" >
	            <p:inputText value="#{measurementEntry.peConductibility}"
	            		styleClass="measurementFormInput measurementFormInputPeConductibility" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol shortCircuitCurrent" >
	            <p:inputText value="#{measurementEntry.shortCircuitCurrent}"
	            		styleClass="measurementFormInput measurementFormInputShortCircuitCurrent" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol insulatingResistance" >
	            <p:inputText value="#{measurementEntry.insulatingResistance}"
	            		styleClass="measurementFormInput measurementFormInputInsulatingResistance" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol insulatingResistanceIsBigger999" >
	            <p:selectBooleanCheckbox value="#{measurementEntry.insulatingResistanceIsBigger999}"
	            		styleClass="measurementFormInput measurementFormInputInsulatingResistanceBigger999" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol fiRatedCurrent" >
	            <p:inputText value="#{measurementEntry.fiRatedCurrent}"
	            		styleClass="measurementFormInput measurementFormInputFiRatedCurrent" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol fiReleaseCurrent" >
	            <p:inputText value="#{measurementEntry.fiReleaseCurrent}"
	            		styleClass="measurementFormInput measurementFormInputFiReleaseCurrent" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol fiTimeInMillis" >
	            <p:inputText value="#{measurementEntry.fiTimeInMillis}"
	            		styleClass="measurementFormInput measurementFormInputFiTimeInMillis" />
	        </p:column>
	        
	        <p:column styleClass="measurementCol rotatingFieldClockwise" >
	            <p:selectBooleanCheckbox value="#{measurementEntry.rotatingFieldClockwise}"
	            		styleClass="measurementFormInput measurementFormInputRotatingFieldClockwise" />
	        </p:column>
	    </p:dataTable>
	    <h:panelGroup styleClass="buttonsSaveDelete">
			<p:commandButton value="Speichern" 
							actionListener="#{measurementFormController.saveMeasurement}"  
							styleClass="electroOffice-button save-button" 
							ajax="false"
							update="measurementForm" />
			<p:commandButton value="Abbrechen"
							actionListener="#{measurementFormController.cancel}"
							styleClass="electroOffice-button cancel-button"
							ajax="false" update="appointmentForm" >
				<p:confirm header="Abbrechen" message="Sind Sie sicher das Sie die Aktion abbrechen wollen? Alle Daten gehen dabei verloren!" icon="ui-icon-alert" />
			</p:commandButton>
			
			<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">  
		        <p:commandButton value="Ja" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>  
		        <p:commandButton value="Nein" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
		    </p:confirmDialog>
		</h:panelGroup>
	</h:form>
</f:view>